import App from './App';
import http from './utils/http.js';
import {logo} from './utils/logo.js';
import uView from '@/uni_modules/uview-ui';
import store from './store';
Vue.use(uView)

// #ifndef VUE3
import Vue from 'vue';
import './uni.promisify.adaptor';
Vue.prototype.$store = store
Vue.prototype.$http=http;
Vue.prototype.$login=logo;
Vue.config.productionTip = false
uni.addInterceptor('request', {
	success(args) {
	if (args.data.errCode == 401) {
		//之前登陆过的token还在必须清空
		uni.setStorageSync('token', null)
		store.commit('Logout', null)
		store.commit('setUserInfo', null)
		uni.showToast({
			title: '登录过期，请重新登录',
			icon: 'none'
		})
		uni.navigateTo({
			url: '/pages/index/index'
		})
		// uni.setStorageSync('isLogin', 'no')
	}
		
	},
	fail(err) {
		console.log('失败')
	}
}),
App.mpType = 'app'
const app = new Vue({
	store,
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif